package com.qf.dto;

import com.qf.constant.ResultBeanConstant;

import java.io.Serializable;
import java.util.HashMap;

/**
 * 作者：李雪琦
 * 项目名：ebookstore
 * 时间：2020/2/4 22:31
 * 描述：
 */
public class ResultBean extends HashMap<String,Object> implements Serializable {

    private static final long serialVersionUID=1L;

    private Integer code;
    private String msg;
    private Object data;

    public ResultBean() {
    }

    public ResultBean(Integer code){
        super.put(ResultBeanConstant.CODE,code);
    }
    public ResultBean(String msg){
        super.put(ResultBeanConstant.MSG,msg);
    }
    public ResultBean(Integer code, String msg){
        super.put(ResultBeanConstant.CODE,code);
        super.put(ResultBeanConstant.MSG,msg);
    }
    public ResultBean(Integer code,String msg,Object data){
        super.put(ResultBeanConstant.CODE,code);
        super.put(ResultBeanConstant.MSG,msg);
        super.put(ResultBeanConstant.DATA,data);
    }

    public static ResultBean ok(){
        return new ResultBean(ResultBeanConstant.SUCCESS_CODE);
    }
    public static ResultBean ok(String msg){
        return new ResultBean(ResultBeanConstant.SUCCESS_CODE,msg);
    }
    public static ResultBean ok(String msg,Object data){return new ResultBean(ResultBeanConstant.SUCCESS_CODE,msg,data);}
    public static ResultBean fail(){
        return new ResultBean(ResultBeanConstant.FAIL_CODE);
    }
    public static ResultBean fail(String msg){
        return new ResultBean(ResultBeanConstant.FAIL_CODE,msg);
    }
    public static ResultBean fail(String msg,Object data){return new ResultBean(ResultBeanConstant.FAIL_CODE,msg,data);}
    public static ResultBean fail(Integer code,String msg,Object data){
        return new ResultBean(code,msg,data);
    }
}
